package com.zhanghe.study.study_scala.generic

/**
 * 测试下界
 * @author zh
 * @date 2021/5/19 10:53
 */
object TestLower {
  def main(args: Array[String]): Unit = {
    def test[T >: Child](obj:T) = {
      // Error:(11, 11) value name is not a member of type parameter T
      //      obj.name()
//      obj.name()

    }

    val parent:Parent = new Parent
    //我是父类
    test(parent)

    val child:Child = new Child
    //我是子类
    test(child)
  }
  class Parent{
    def name() = {
      println("我是父类")
    }
  }

  class Child extends Parent {
    override def name() = {
      println("我是子类")
    }
  }

}
